﻿// Copyright richyp 2009
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Richyp.Bodger.UI {
    public partial class OptionDialog : Form {
        public OptionDialog() {
            InitializeComponent();
        }

        public void Populate(Equipment defaultItem, List<ReplacementEntry> entries) {
            this.groupBoxReplacement.Controls.Clear();
            int y = 10;
            foreach( ReplacementEntry entry in entries ) {
                RadioButton button = new RadioButton();
                if (entry.Equipment.Wargear.Name == defaultItem.Wargear.Name) {
                    button.Checked = true;
                }
                button.Text = entry.Equipment.Wargear.Name;
                button.Tag = entry;
                button.Top = y;
                button.Left = 5;
                this.groupBoxReplacement.Controls.Add(button);
                y+= button.Height;
            }
        }

        public ReplacementEntry Chosen {
            get {
                foreach( Control button in this.groupBoxReplacement.Controls) {
                    if( button is RadioButton ) {
                        if(((RadioButton)button).Checked ) {
                            return (ReplacementEntry)button.Tag;
                        }
                    }
                }
                return null;
            }
        }
    }
}
